package indi.caspar.algorithms.sort;

/**
 * Created by casparhuan on 2017/6/17.
 */
public class SortsAlgUtil {

    public static boolean less(Comparable val1,Comparable val2) {
        return val1.compareTo(val2) < 0;
    }

    public static void exch(Comparable[] a , int i ,int k){
        Comparable temp = a[i];
        a[i] = a[k];
        a[k] = temp;
    }

    public static boolean isSorted(Comparable[] a){
        for (int i = 1; i < a.length ; i++) {
            if (less(a[i],a[i-1])){
                return false;
            }
        }
        return true;
    }

    public static void show(Comparable[] a){
        for (Comparable val:a){
            System.out.print(val + "  ");
        }
        System.out.println("");
    }
}
